/*
 * PyTuple.h
 *
 *  Created on: 3 Apr 2012
 *      Author: allan
 */

#ifndef PYTUPLE_H_
#define PYTUPLE_H_

// C++ includes
#include <tuple>

// Boost includes
#include <boost/python.hpp>
using namespace boost::python;

template<typename T0>
void export_std_tuple()
{
	struct std_tuple_to_python_tuple
	{
		static PyObject* convert(const std::tuple<T0>& p)
		{
			tuple t = make_tuple(std::get<0>(p));
			
			return incref(t.ptr());
		}
	};
	
	to_python_converter<std::tuple<T0>, std_tuple_to_python_tuple>();
}

template<typename T0, typename T1>
void export_std_tuple()
{
	struct std_tuple_to_python_tuple
	{
		static PyObject* convert(const std::tuple<T0, T1>& p)
		{
			tuple t = make_tuple(std::get<0>(p), std::get<1>(p));
			
			return incref(t.ptr());
		}
	};
	
	to_python_converter<std::tuple<T0, T1>, std_tuple_to_python_tuple>();
}

template<typename T0, typename T1, typename T2>
void export_std_tuple()
{
	struct std_tuple_to_python_tuple
	{
		static PyObject* convert(const std::tuple<T0, T1, T2>& p)
		{
			tuple t = make_tuple(std::get<0>(p), std::get<1>(p), std::get<2>(p));
			
			return incref(t.ptr());
		}
	};
	
	to_python_converter<std::tuple<T0, T1, T2>, std_tuple_to_python_tuple>();
}

#endif /* PYTUPLE_H_ */
